CentOS 7
Sponsored Link

Cgroups : Install
2017/08/30
 
It's possible to allocate resources or monitoring, such as CPU time, system memory with Control Groups (Cgroups).
[1] Install packages to use Cgroups.
[root@dlp ~]#
yum -y install libcgroup libcgroup-tools
[root@dlp ~]#
systemctl start cgconfig

[root@dlp ~]#
systemctl enable cgconfig
[2] Because Systemd uses Cgroups, [libcgroup] package is installed by default, though. Some controlers for each subsystem are mounted under the [/sys/fs/cgroup] like follows by default. The subsystem on Cgroups means a resource like CPu or memory and so on.
[root@dlp ~]#
ll /sys/fs/cgroup

total 0
drwxr-xr-x. 2 root root  0 Aug 30 09:23 blkio
lrwxrwxrwx. 1 root root 11 Aug 30 09:23 cpu -> cpu,cpuacct
lrwxrwxrwx. 1 root root 11 Aug 30 09:23 cpuacct -> cpu,cpuacct
drwxr-xr-x. 2 root root  0 Aug 30 09:23 cpu,cpuacct
drwxr-xr-x. 2 root root  0 Aug 30 09:23 cpuset
drwxr-xr-x. 4 root root  0 Aug 30 09:23 devices
drwxr-xr-x. 2 root root  0 Aug 30 09:23 freezer
drwxr-xr-x. 2 root root  0 Aug 30 09:23 hugetlb
drwxr-xr-x. 2 root root  0 Aug 30 09:23 memory
lrwxrwxrwx. 1 root root 16 Aug 30 09:23 net_cls -> net_cls,net_prio
drwxr-xr-x. 2 root root  0 Aug 30 09:23 net_cls,net_prio
lrwxrwxrwx. 1 root root 16 Aug 30 09:23 net_prio -> net_cls,net_prio
drwxr-xr-x. 2 root root  0 Aug 30 09:23 perf_event
drwxr-xr-x. 2 root root  0 Aug 30 09:23 pids
drwxr-xr-x. 4 root root  0 Aug 30 09:23 systemd
blkio It limits on input/output access to and from block devices.
cpu It uses the scheduler to provide cgroup tasks access to the CPU.
cpuacct It generates automatic reports on CPU resources.
cpuset It assigns individual CPUs on a multicore system and memory nodes to tasks.
devices It allows or denies access to devices by tasks.
freezer It suspends or resumes tasks in a cgroup.
hugetlb It limits to use HugeTLB.
memory It limits on memory use by tasks and generates automatic reports on memory resources.
net_cls It tags network packets with a class identifier (classid).
net_prio It provides a way to dynamically set the priority of network traffic per network interface.
perf_event It identifies cgroup membership of tasks and can be used for performance analysis.
pids It limits number of processes.

[3] It's possible to make sure current Control Grouos like follows.
This is the default state on minimal installation.
[root@dlp ~]#
lscgroup

cpuset:/
net_cls,net_prio:/
blkio:/
cpu,cpuacct:/
perf_event:/
memory:/
pids:/
freezer:/
hugetlb:/
devices:/
devices:/user.slice
devices:/system.slice
devices:/system.slice/rsyslog.service
devices:/system.slice/tuned.service
devices:/system.slice/sshd.service
devices:/system.slice/postfix.service
devices:/system.slice/polkit.service
devices:/system.slice/crond.service
devices:/system.slice/systemd-udevd.service
devices:/system.slice/dbus.service
devices:/system.slice/irqbalance.service
devices:/system.slice/lvm2-lvmetad.service
devices:/system.slice/auditd.service
devices:/system.slice/system-getty.slice
devices:/system.slice/chronyd.service
devices:/system.slice/NetworkManager.service
devices:/system.slice/systemd-logind.service
devices:/system.slice/systemd-journald.service
devices:/system.slice/firewalld.service
[4] By the way, it's possible to make sure default Systemd Control Groups like follows.
[root@dlp ~]#
systemd-cgls

+--1 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
+--user.slice
| +--user-0.slice
|   +--session-1.scope
|     +-- 791 login -- root
|     +--1095 -bash
|     +--8395 systemd-cgls
|     +--8396 less
+--system.slice
  +--rsyslog.service
  | +--986 /usr/sbin/rsyslogd -n
  +--tuned.service
  | +--985 /usr/bin/python -Es /usr/sbin/tuned -l -P
  +--sshd.service
  | +--984 /usr/sbin/sshd -D
  +--postfix.service
  | +--1084 /usr/libexec/postfix/master -w
  | +--1086 qmgr -l -t unix -u
  | +--8359 pickup -l -t unix -u
  +--NetworkManager.service
  | +--647 /usr/sbin/NetworkManager --no-daemon
  +--firewalld.service
  | +--641 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
  +--crond.service
  | +--634 /usr/sbin/crond -n
  +--dbus.service
  | +--619 /bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --sy
  +--polkit.service
  | +--618 /usr/lib/polkit-1/polkitd --no-debug
  +--irqbalance.service
  | +--616 /usr/sbin/irqbalance --foreground
  +--chronyd.service
  | +--622 /usr/sbin/chronyd
  +--systemd-logind.service
  | +--613 /usr/lib/systemd/systemd-logind
  +--auditd.service
  | +--591 /sbin/auditd -n
  | +--597 /sbin/audispd
  | +--602 /usr/sbin/sedispatch
  +--systemd-udevd.service
  | +--487 /usr/lib/systemd/systemd-udevd
  +--lvm2-lvmetad.service
  | +--477 /usr/sbin/lvmetad -f
  +--system-getty.slice
  | +--getty@tty1.service
  |   +--645 /sbin/agetty --noclear tty1 linux
  +--systemd-journald.service
    +--462 /usr/lib/systemd/systemd-journald
 
Tweet